/*
 * File      : fal.h
 * This file is part of FAL (Flash Abstraction Layer) package
 * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-05-17     armink       the first version
 */

#ifndef _FAL_PORT_H_
#define _FAL_PORT_H_

#include <fal_cfg.h>
#include <fal_def.h>
#include <flashdb.h>

/**
@brief  FlashDB初始化
@return -1=初始化失败
**/
fdb_err_t fdb_init(fdb_kvdb_t *handle);
/**
@brief 采用键-值方式设置
@param handle-分区表句柄
@param key-键
@param pdata-值
@param len-写入数据长度
@return fdb_err_t状态
**/
fdb_err_t fdb_set_value(fdb_kvdb_t handle, const char *key, uint8_t *pdata, uint16_t len);

/**
@brief 采用键-值方式读数据
@param handle-分区表句柄
@param key-键
@param pdata-值
@param len-写入数据长度
@return 0=没有找到key, 非0=读取的数据长度
**/
size_t fdb_get_value(fdb_kvdb_t handle, const char *key, uint8_t *pdata, uint16_t len);

#endif /* _FAL_PORT_H_ */

